package fr.paris.lutece.plugins.techos.dto.chat;

import java.util.Iterator;
import java.util.List;

import org.dozer.Mapper;
import org.hibernate.validator.constraints.NotEmpty;

import fr.paris.lutece.plugins.genericjpa.dao.commons.ResultList;
import fr.paris.lutece.plugins.genericjpa.dto.GenericJPADTO;
import fr.paris.lutece.plugins.techos.bean.chat.Chat;
import fr.paris.lutece.portal.service.spring.SpringContextService;


/**
 * The Chat class DTO
 * @author jchaline
 */
public class ChatDTO extends GenericJPADTO<Integer, Chat>
{
    private Integer _id;

    @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" )
    private String _date;

    @NotEmpty( message = "#i18n{portal.validation.message.notEmpty}" )
    private String _strName;

    /**
     * 
     * @param date
     */
    public void setDate( String date )
    {
        this._date = date;
    }

    /**
     * 
     * @return
     */
    public String getDate( )
    {
        return this._date;
    }

    /**
	 * 
	 */
    public void setId( Integer id )
    {
        this._id = id;
    }

    /**
	 * 
	 */
    public Integer getId( )
    {
        return this._id;
    }

    /**
     * 
     * @param name
     */
    public void setName( String name )
    {
        this._strName = name;
    }

    /**
     * 
     * @return
     */
    public String getName( )
    {
        return this._strName;
    }

    @Override
    public Chat convert( )
    {
        Chat target = _dozerMapper.map( this, Chat.class );
        return target;
    }

    /**
     * Convert bean into DTO
     * @param source the bean source
     * @return the dto converted
     */
    public static ChatDTO convertEntity( Chat source )
    {
        Mapper _dozerMapper = (Mapper) SpringContextService.getBean( "mapper" );
        ChatDTO target = _dozerMapper.map( source, ChatDTO.class );
        return target;
    }

    /**
     * Convert list bean into DTO
     * @param listSource the list bean source
     * @return the list of dto converted
     */
    public static List<ChatDTO> convertEntities( List<Chat> listSource )
    {
        List<ChatDTO> listTarget = new ResultList<ChatDTO>( );
        for ( Iterator<Chat> chatIter = listSource.iterator( ); chatIter.hasNext( ); )
        {
            listTarget.add( convertEntity( chatIter.next( ) ) );
        }
        return listTarget;
    }
}